package iosr11.example;

import iosr11.Service.MarkService;
import iosr11.Service.ServiceLocator;
import iosr11.Service.ServiceLocatorImpl_old;
import iosr11.Service.StudentService;
import iosr11.Service.TeacherService;
import iosr11.data.Mark;
import iosr11.data.MarkKind;
import iosr11.data.Student;
import iosr11.data.Teacher;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class MarkMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*DAOLocator factory = DAOLocatorImpl.getInstance();
		Student student = ((StudentDAO)factory.getDAO(Student.class)).getByLogin("kowalski@email.com");
		Teacher teacher = ((TeacherDAO)factory.getDAO(Teacher.class)).getByLogin("Teacher 1");
		
		System.out.println("--> Dane wejsciowe <--");
		System.out.println(student);
		System.out.println(teacher);
		
		//float grade, Teacher teacher, Student student, int kind, DateTime date, 
		//float points, String markId
		//Mark mark = new Mark((float) 4.5,teacher,student,1,new DateTime(), 20, null);
		//System.out.println("mark do dodania "+ mark);
		//System.out.println(((MarkDAO)factory.getDAO(Mark.class)).add(mark));
		
		System.out.println(((MarkDAO)factory.getDAO(Mark.class)).getStudentMarks(student));
		// */
		
		ServiceLocator locator = ServiceLocatorImpl_old.getInstance();
		StudentService studentS = (StudentService) locator.getService(Student.class);
		TeacherService teacherS = (TeacherService) locator.getService(Teacher.class);
		MarkService markS = (MarkService) locator.getService(Mark.class);
		
		Student st = studentS.getStudent("adam.k@gmail.com");
		System.out.println(st);
		
		List<Teacher> teachers = teacherS.getAllTeachers();
		
		System.out.println(teachers);
		
		Teacher te = teacherS.getTeacher("teacher3@gmail.com");
		System.out.println(te);
		
		Mark mark = new Mark();
		Date date = new Date(Calendar.getInstance().getTimeInMillis());
		mark.setDate(date);
		mark.setGrade(3.5f);
		mark.setKind(MarkKind.PROJECT);
		mark.setPoints(40f);
		mark.setStudent(st);
		mark.setTeacher(te);
		
		System.out.println(mark);
		
		
		/*
		Mark mk = st.getGrades().get(0);
		System.out.println(mk);
		System.out.println(markS.deleteMark(mk));
		//System.out.println(markS.addMark(st, te, mark));*/
	}

}
